package com.liang.mybatis01;

import com.liang.mybatis01.mapper.UserMapper;
import com.liang.mybatis01.utils.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.ArrayList;
import java.util.HashMap;

public class MybatisTest3 {
    public static void main(String[] args) {
        SqlSession sqlSession = MybatisUtil.getSqlSession();
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        HashMap<String, Object> map = new HashMap<>();
        ArrayList<String> keys = new ArrayList<>();
        ArrayList<Object> values = new ArrayList<>();
//        keys集合按索引对应values值
        keys.add("userCode");
        keys.add("userName");
        keys.add("userPassword");
        values.add("wangwang");
        values.add("老王");
        values.add("123456");

        map.put("keys",keys);
        map.put("values",values);

        int i = mapper.foreachInsert(map);
        System.out.println(i);

        sqlSession.commit();
        sqlSession.close();
    }
}
